﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Modelo;

namespace Interface
{
    /// <summary>
    /// Interaction logic for RegistrarPago.xaml
    /// </summary>
    public partial class RegistrarPago : UserControl
    {
        List<EmpleadoSalario> salarios = new List<EmpleadoSalario>();
        public RegistrarPago()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                salarios=Proceso.GestorEmpleado.buscarPorCi(textBox1.Text,textBox2.Text,textBox3.Text);
                dataGrid1.ItemsSource = salarios;
            }
            catch (Exception)
            { 
            }
        }

        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid1.SelectedIndex > -1)
            {
                try
                {
                    ConfirmarPago p = new ConfirmarPago(salarios[dataGrid1.SelectedIndex]);
                    p.ShowDialog();
                }
                catch (InvalidOperationException)
                {
                }
            }
            else
                MessageBox.Show("Seleccione un empleado");
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid1.SelectedIndex > -1)
            {
                try
                {
                    EditarPago ver = new EditarPago(salarios[dataGrid1.SelectedIndex].Usuario);
                    ver.ShowDialog();
                }
                catch (InvalidOperationException)
                {
                }
            }
            else
                MessageBox.Show("Seleccione un empleado");
        
        }

        private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (String.IsNullOrEmpty(textBox1.Text))
            {
                textBox2.IsEnabled = true;
                textBox3.IsEnabled = true;
            }
            else
            {
                textBox2.IsEnabled = false;
                textBox3.IsEnabled = false;
            
            }
        }
    }
}
